<template>
  <div class="video-converter">
    <div class="container">
      <header class="tool-header">
        <h1>视频格式转换工具</h1>
        <p class="subtitle">在线转换视频格式，支持多种输出选项</p>
      </header>

      <div class="tool-content">
        <!-- 上传区域 -->
        <div class="upload-section">
          <div
            class="upload-area"
            @click="triggerFileInput"
            @drop="handleDrop"
            @dragover.prevent
            :class="{ dragover: isDragover, 'has-video': !!videoInfo }"
          >
            <input
              type="file"
              ref="fileInput"
              @change="handleFileSelect"
              accept="video/*"
              style="display: none"
            />
            <div class="upload-icon">
              <span v-if="!videoInfo">🎬</span>
              <video
                v-else-if="videoPreview"
                :src="videoPreview"
                class="preview-video"
                controls
              ></video>
              <span v-else>📁</span>
            </div>
            <p v-if="!videoInfo">点击选择视频或拖拽视频到这里</p>
            <div v-else class="video-info">
              <p class="video-name">{{ videoInfo.name }}</p>
              <p class="video-details">
                {{ formatFileSize(videoInfo.size) }} • {{ videoInfo.duration }}
              </p>
            </div>
            <small>支持 MP4, AVI, MOV, WebM 等格式，最大 500MB</small>
          </div>

          <div v-if="videoInfo" class="upload-actions">
            <button @click="analyzeVideo" class="analyze-btn" :disabled="isAnalyzing">
              {{ isAnalyzing ? '分析中...' : '🔍 分析视频' }}
            </button>
            <button @click="clearVideo" class="clear-btn">清除视频</button>
          </div>
        </div>

        <!-- 视频信息 -->
        <div v-if="videoAnalysis" class="analysis-section">
          <h3>视频分析结果</h3>
          <div class="analysis-grid">
            <div class="analysis-item">
              <span class="analysis-label">格式</span>
              <span class="analysis-value">{{ videoAnalysis.format }}</span>
            </div>
            <div class="analysis-item">
              <span class="analysis-label">时长</span>
              <span class="analysis-value">{{ videoAnalysis.duration }}</span>
            </div>
            <div class="analysis-item">
              <span class="analysis-label">分辨率</span>
              <span class="analysis-value">{{ videoAnalysis.resolution }}</span>
            </div>
            <div class="analysis-item">
              <span class="analysis-label">帧率</span>
              <span class="analysis-value">{{ videoAnalysis.fps }} fps</span>
            </div>
            <div class="analysis-item">
              <span class="analysis-label">码率</span>
              <span class="analysis-value">{{ videoAnalysis.bitrate }}</span>
            </div>
            <div class="analysis-item">
              <span class="analysis-label">文件大小</span>
              <span class="analysis-value">{{ videoAnalysis.size }}</span>
            </div>
          </div>
        </div>

        <!-- 转换选项 -->
        <div v-if="videoInfo" class="options-section">
          <h3>转换设置</h3>
          <div class="options-grid">
            <div class="option-group">
              <label>输出格式：</label>
              <select v-model="conversionOptions.outputFormat">
                <option value="mp4">MP4 (H.264)</option>
                <option value="webm">WebM (VP9)</option>
                <option value="avi">AVI</option>
                <option value="mov">MOV</option>
                <option value="gif">GIF</option>
                <option value="mp3">MP3 (音频提取)</option>
              </select>
            </div>

            <div class="option-group">
              <label>视频质量：</label>
              <select v-model="conversionOptions.quality">
                <option value="high">高质量</option>
                <option value="medium">中等质量</option>
                <option value="low">低质量</option>
                <option value="custom">自定义</option>
              </select>
            </div>

            <div class="option-group" v-if="conversionOptions.quality === 'custom'">
              <label>目标码率：</label>
              <div class="slider-container">
                <input
                  type="range"
                  v-model="conversionOptions.bitrate"
                  min="500"
                  max="10000"
                  step="100"
                  class="bitrate-slider"
                />
                <span class="slider-value">{{ conversionOptions.bitrate }} kbps</span>
              </div>
            </div>

            <div class="option-group">
              <label>分辨率：</label>
              <select v-model="conversionOptions.resolution">
                <option value="original">原分辨率</option>
                <option value="1080p">1080p (1920×1080)</option>
                <option value="720p">720p (1280×720)</option>
                <option value="480p">480p (854×480)</option>
                <option value="360p">360p (640×360)</option>
                <option value="custom">自定义</option>
              </select>
            </div>

            <div class="option-group" v-if="conversionOptions.resolution === 'custom'">
              <label>自定义分辨率：</label>
              <div class="resolution-inputs">
                <input
                  type="number"
                  v-model="conversionOptions.customWidth"
                  placeholder="宽度"
                  min="100"
                  max="3840"
                />
                <span>×</span>
                <input
                  type="number"
                  v-model="conversionOptions.customHeight"
                  placeholder="高度"
                  min="100"
                  max="2160"
                />
              </div>
            </div>

            <div class="option-group">
              <label>帧率：</label>
              <select v-model="conversionOptions.fps">
                <option value="original">原帧率</option>
                <option value="30">30 fps</option>
                <option value="25">25 fps</option>
                <option value="24">24 fps</option>
                <option value="15">15 fps</option>
              </select>
            </div>

            <div class="option-group">
              <label class="checkbox-label">
                <input type="checkbox" v-model="conversionOptions.keepAudio" />
                <span class="checkmark"></span>
                保留音频
              </label>
            </div>

            <div class="option-group">
              <label class="checkbox-label">
                <input type="checkbox" v-model="conversionOptions.optimizeSize" />
                <span class="checkmark"></span>
                优化文件大小
              </label>
            </div>

            <div class="option-group">
              <label>转换速度：</label>
              <select v-model="conversionOptions.speed">
                <option value="slow">慢速（高质量）</option>
                <option value="medium">中速</option>
                <option value="fast">快速（低质量）</option>
              </select>
            </div>
          </div>
        </div>

        <!-- 高级选项 -->
        <div v-if="videoInfo && showAdvanced" class="advanced-section">
          <h3 @click="toggleAdvanced" class="advanced-toggle">
            <span>高级选项</span>
            <span class="toggle-icon">{{ showAdvanced ? '▼' : '▶' }}</span>
          </h3>
          <div v-if="showAdvanced" class="advanced-content">
            <div class="options-grid">
              <div class="option-group">
                <label>视频编码器：</label>
                <select v-model="conversionOptions.videoCodec">
                  <option value="h264">H.264</option>
                  <option value="h265">H.265 (HEVC)</option>
                  <option value="vp9">VP9</option>
                  <option value="av1">AV1</option>
                </select>
              </div>

              <div class="option-group">
                <label>音频编码器：</label>
                <select v-model="conversionOptions.audioCodec">
                  <option value="aac">AAC</option>
                  <option value="mp3">MP3</option>
                  <option value="opus">Opus</option>
                  <option value="flac">FLAC</option>
                </select>
              </div>

              <div class="option-group">
                <label>音频码率：</label>
                <select v-model="conversionOptions.audioBitrate">
                  <option value="128">128 kbps</option>
                  <option value="192">192 kbps</option>
                  <option value="256">256 kbps</option>
                  <option value="320">320 kbps</option>
                </select>
              </div>

              <div class="option-group">
                <label>关键帧间隔：</label>
                <input
                  type="number"
                  v-model="conversionOptions.keyframeInterval"
                  min="1"
                  max="300"
                />
                <small>帧数</small>
              </div>
            </div>
          </div>
        </div>

        <!-- 转换控制 -->
        <div v-if="videoInfo" class="conversion-section">
          <div class="conversion-header">
            <h3>转换控制</h3>
            <div class="conversion-actions">
              <button
                @click="startConversion"
                class="convert-btn"
                :disabled="isConverting || !videoInfo"
              >
                {{ isConverting ? '转换中...' : '🚀 开始转换' }}
              </button>
              <button @click="cancelConversion" class="cancel-btn" :disabled="!isConverting">
                取消转换
              </button>
            </div>
          </div>

          <div v-if="conversionProgress > 0" class="progress-section">
            <div class="progress-info">
              <span class="progress-label">转换进度</span>
              <span class="progress-percentage">{{ Math.round(conversionProgress) }}%</span>
            </div>
            <div class="progress-bar">
              <div class="progress-fill" :style="{ width: conversionProgress + '%' }"></div>
            </div>
            <div class="progress-details">
              <span>已用时间: {{ elapsedTime }}</span>
              <span>预计剩余: {{ remainingTime }}</span>
              <span>当前状态: {{ conversionStatus }}</span>
            </div>
          </div>
        </div>

        <!-- 转换结果 -->
        <div v-if="convertedVideo" class="result-section">
          <h3>转换结果</h3>
          <div class="result-content">
            <div class="result-preview">
              <video :src="convertedVideo.url" controls class="result-video"></video>
            </div>
            <div class="result-info">
              <div class="result-details">
                <div class="detail-item">
                  <span class="detail-label">输出格式:</span>
                  <span class="detail-value">{{ convertedVideo.format }}</span>
                </div>
                <div class="detail-item">
                  <span class="detail-label">文件大小:</span>
                  <span class="detail-value">{{ convertedVideo.size }}</span>
                </div>
                <div class="detail-item">
                  <span class="detail-label">分辨率:</span>
                  <span class="detail-value">{{ convertedVideo.resolution }}</span>
                </div>
                <div class="detail-item">
                  <span class="detail-label">压缩率:</span>
                  <span
                    class="detail-value"
                    :class="getCompressionClass(convertedVideo.compressionRatio)"
                  >
                    {{ convertedVideo.compressionRatio }}%
                  </span>
                </div>
              </div>
              <div class="result-actions">
                <button @click="downloadVideo" class="download-btn">📥 下载视频</button>
                <button @click="convertAnother" class="another-btn">再次转换</button>
              </div>
            </div>
          </div>
        </div>

        <!-- 格式说明 -->
        <div class="info-section">
          <h3>格式说明</h3>
          <div class="format-info">
            <div class="format-item">
              <strong>MP4</strong> - 最兼容的格式，适合网页播放和移动设备
            </div>
            <div class="format-item"><strong>WebM</strong> - 开源格式，适合现代浏览器</div>
            <div class="format-item"><strong>GIF</strong> - 适合短动画和表情包</div>
            <div class="format-item"><strong>MP3</strong> - 仅提取音频，适合音乐和播客</div>
          </div>
        </div>
      </div>

      <footer class="tool-footer">
        <p>© 2023 Vue 3 视频格式转换工具</p>
      </footer>
    </div>
  </div>
</template>

<script setup>
import { ref, computed, watch } from 'vue'

// 响应式数据
const fileInput = ref(null)
const videoInfo = ref(null)
const videoPreview = ref('')
const videoAnalysis = ref(null)
const isAnalyzing = ref(false)
const isConverting = ref(false)
const isDragover = ref(false)
const showAdvanced = ref(false)
const conversionProgress = ref(0)
const conversionStatus = ref('准备中')
const convertedVideo = ref(null)
const conversionInterval = ref(null)

// 转换选项
const conversionOptions = ref({
  outputFormat: 'mp4',
  quality: 'medium',
  bitrate: 2000,
  resolution: 'original',
  customWidth: 1920,
  customHeight: 1080,
  fps: 'original',
  keepAudio: true,
  optimizeSize: true,
  speed: 'medium',
  videoCodec: 'h264',
  audioCodec: 'aac',
  audioBitrate: '128',
  keyframeInterval: 30
})

// 触发文件选择
const triggerFileInput = () => {
  fileInput.value?.click()
}

// 处理文件选择
const handleFileSelect = (event) => {
  const file = event.target.files[0]
  if (file) {
    loadVideo(file)
  }
}

// 处理拖拽
const handleDrop = (event) => {
  event.preventDefault()
  isDragover.value = false
  const file = event.dataTransfer.files[0]
  if (file && file.type.startsWith('video/')) {
    loadVideo(file)
  }
}

// 加载视频
const loadVideo = (file) => {
  if (file.size > 500 * 1024 * 1024) {
    alert('视频大小不能超过500MB')
    return
  }

  const reader = new FileReader()
  reader.onload = (e) => {
    videoPreview.value = e.target.result
    videoInfo.value = {
      name: file.name,
      size: file.size,
      type: file.type,
      duration: '未知'
    }

    // 模拟获取视频时长
    getVideoDuration(file).then(duration => {
      videoInfo.value.duration = formatDuration(duration)
    })
  }
  reader.readAsDataURL(file)
}

// 获取视频时长
const getVideoDuration = (file) => {
  return new Promise((resolve) => {
    const video = document.createElement('video')
    video.preload = 'metadata'
    video.onloadedmetadata = () => {
      resolve(video.duration)
    }
    video.src = URL.createObjectURL(file)
  })
}

// 分析视频
const analyzeVideo = async () => {
  if (!videoInfo.value) return

  isAnalyzing.value = true
  conversionProgress.value = 0

  // 模拟分析过程
  for (let i = 0; i <= 100; i += 10) {
    conversionProgress.value = i
    conversionStatus.value = `分析视频信息... ${i}%`
    await new Promise(resolve => setTimeout(resolve, 200))
  }

  // 模拟分析结果
  videoAnalysis.value = {
    format: videoInfo.value.name.split('.').pop().toUpperCase(),
    duration: videoInfo.value.duration,
    resolution: '1920×1080',
    fps: '30.00',
    bitrate: '4500 kbps',
    size: formatFileSize(videoInfo.value.size)
  }

  isAnalyzing.value = false
  conversionProgress.value = 0
  conversionStatus.value = '分析完成'
}

// 开始转换
const startConversion = async () => {
  if (!videoInfo.value || isConverting.value) return

  isConverting.value = true
  conversionProgress.value = 0
  conversionStatus.value = '准备转换...'

  // 模拟转换过程
  conversionInterval.value = setInterval(() => {
    if (conversionProgress.value < 100) {
      conversionProgress.value += Math.random() * 5
      conversionStatus.value = getConversionStatus(conversionProgress.value)
    } else {
      completeConversion()
    }
  }, 500)
}

// 获取转换状态
const getConversionStatus = (progress) => {
  if (progress < 20) return '初始化转换器...'
  if (progress < 40) return '解码视频流...'
  if (progress < 60) return '重新编码视频...'
  if (progress < 80) return '处理音频...'
  if (progress < 95) return '合成输出文件...'
  return '完成转换...'
}

// 完成转换
const completeConversion = () => {
  clearInterval(conversionInterval.value)
  conversionProgress.value = 100
  conversionStatus.value = '转换完成'

  // 模拟转换结果
  const originalSize = videoInfo.value.size
  const compressedSize = originalSize * (0.3 + Math.random() * 0.4) // 30-70% 压缩率

  convertedVideo.value = {
    url: videoPreview.value, // 实际项目中应该是转换后的URL
    format: conversionOptions.value.outputFormat.toUpperCase(),
    size: formatFileSize(compressedSize),
    resolution: getOutputResolution(),
    compressionRatio: Math.round((1 - compressedSize / originalSize) * 100)
  }

  isConverting.value = false
}

// 获取输出分辨率
const getOutputResolution = () => {
  switch (conversionOptions.value.resolution) {
    case '1080p': return '1920×1080'
    case '720p': return '1280×720'
    case '480p': return '854×480'
    case '360p': return '640×360'
    case 'custom': return `${conversionOptions.value.customWidth}×${conversionOptions.value.customHeight}`
    default: return '1920×1080'
  }
}

// 取消转换
const cancelConversion = () => {
  if (conversionInterval.value) {
    clearInterval(conversionInterval.value)
    conversionInterval.value = null
  }
  isConverting.value = false
  conversionProgress.value = 0
  conversionStatus.value = '转换已取消'
}

// 下载视频
const downloadVideo = () => {
  if (!convertedVideo.value) return

  const link = document.createElement('a')
  link.href = convertedVideo.value.url
  link.download = `converted.${conversionOptions.value.outputFormat}`
  link.click()
}

// 再次转换
const convertAnother = () => {
  convertedVideo.value = null
  conversionProgress.value = 0
  conversionStatus.value = '准备中'
}

// 清除视频
const clearVideo = () => {
  videoInfo.value = null
  videoPreview.value = ''
  videoAnalysis.value = null
  convertedVideo.value = null
  conversionProgress.value = 0
  fileInput.value.value = ''
}

// 切换高级选项
const toggleAdvanced = () => {
  showAdvanced.value = !showAdvanced.value
}

// 格式化文件大小
const formatFileSize = (bytes) => {
  if (bytes === 0) return '0 B'
  const k = 1024
  const sizes = ['B', 'KB', 'MB', 'GB']
  const i = Math.floor(Math.log(bytes) / Math.log(k))
  return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
}

// 格式化时长
const formatDuration = (seconds) => {
  const minutes = Math.floor(seconds / 60)
  const remainingSeconds = Math.floor(seconds % 60)
  return `${minutes}:${remainingSeconds.toString().padStart(2, '0')}`
}

// 获取压缩率样式类
const getCompressionClass = (ratio) => {
  if (ratio > 50) return 'high-compression'
  if (ratio > 20) return 'medium-compression'
  return 'low-compression'
}

// 计算已用时间
const elapsedTime = computed(() => {
  const minutes = Math.floor(conversionProgress.value / 20)
  const seconds = Math.floor((conversionProgress.value % 20) * 3)
  return `${minutes}:${seconds.toString().padStart(2, '0')}`
})

// 计算剩余时间
const remainingTime = computed(() => {
  const remaining = 100 - conversionProgress.value
  const minutes = Math.floor(remaining / 20)
  const seconds = Math.floor((remaining % 20) * 3)
  return `${minutes}:${seconds.toString().padStart(2, '0')}`
})

// 监听拖拽状态
watch(isDragover, (newVal) => {
  if (newVal) {
    setTimeout(() => {
      isDragover.value = false
    }, 100)
  }
})

// 监听输出格式变化
watch(() => conversionOptions.value.outputFormat, (newFormat) => {
  if (newFormat === 'mp3') {
    conversionOptions.value.keepAudio = true
  } else if (newFormat === 'gif') {
    conversionOptions.value.keepAudio = false
    conversionOptions.value.fps = '15'
  }
})
</script>

<style scoped>
.video-converter {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.tool-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 30px;
  text-align: center;
  border-radius: 12px 12px 0 0;
}

.tool-header h1 {
  margin: 0 0 10px 0;
  font-size: 2.2em;
}

.subtitle {
  margin: 0;
  opacity: 0.9;
  font-size: 1.1em;
}

.tool-content {
  padding: 30px;
}

.upload-section {
  margin-bottom: 30px;
}

.upload-area {
  border: 2px dashed #667eea;
  border-radius: 8px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: #f8f9ff;
  position: relative;
  overflow: hidden;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: #764ba2;
  background: #f0f2ff;
  transform: translateY(-2px);
}

.upload-area.has-video {
  padding: 20px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-icon {
  font-size: 3em;
  margin-bottom: 15px;
}

.preview-video {
  max-width: 300px;
  max-height: 200px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.video-info {
  margin: 10px 0;
}

.video-name {
  font-weight: 600;
  color: #333;
  margin-bottom: 5px;
}

.video-details {
  color: #666;
  font-size: 14px;
}

.upload-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 20px;
}

.analyze-btn,
.clear-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.analyze-btn {
  background: #4caf50;
  color: white;
}

.analyze-btn:hover:not(:disabled) {
  background: #45a049;
  transform: translateY(-2px);
}

.analyze-btn:disabled {
  background: #cccccc;
  cursor: not-allowed;
}

.clear-btn {
  background: #ff9800;
  color: white;
}

.clear-btn:hover {
  background: #f57c00;
  transform: translateY(-2px);
}

.analysis-section {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 30px;
}

.analysis-section h3 {
  margin-bottom: 15px;
  color: #333;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.analysis-item {
  background: white;
  padding: 15px;
  border-radius: 6px;
  border-left: 4px solid #667eea;
}

.analysis-label {
  display: block;
  font-weight: 600;
  color: #666;
  font-size: 14px;
  margin-bottom: 5px;
}

.analysis-value {
  display: block;
  font-size: 1.2em;
  font-weight: 600;
  color: #333;
}

.options-section {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.options-section h3 {
  margin-bottom: 15px;
  color: #333;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-group label {
  font-weight: 600;
  color: #555;
}

select,
input[type='number'] {
  padding: 8px 12px;
  border: 2px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 15px;
}

.bitrate-slider {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: #ddd;
  outline: none;
}

.bitrate-slider::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #667eea;
  cursor: pointer;
}

.slider-value {
  font-weight: 600;
  color: #667eea;
  min-width: 100px;
}

.resolution-inputs {
  display: flex;
  align-items: center;
  gap: 10px;
}

.resolution-inputs input {
  width: 80px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-label input {
  display: none;
}

.checkmark {
  width: 18px;
  height: 18px;
  border: 2px solid #ddd;
  border-radius: 3px;
  position: relative;
  transition: all 0.3s;
}

.checkbox-label input:checked + .checkmark {
  background: #667eea;
  border-color: #667eea;
}

.checkbox-label input:checked + .checkmark::after {
  content: '✓';
  position: absolute;
  color: white;
  font-size: 12px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.advanced-section {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 30px;
}

.advanced-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  margin: 0;
  color: #333;
}

.toggle-icon {
  font-size: 12px;
}

.advanced-content {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #ddd;
}

.conversion-section {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 30px;
}

.conversion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.conversion-header h3 {
  margin: 0;
  color: #333;
}

.conversion-actions {
  display: flex;
  gap: 10px;
}

.convert-btn,
.cancel-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.convert-btn {
  background: #2196f3;
  color: white;
}

.convert-btn:hover:not(:disabled) {
  background: #1976d2;
  transform: translateY(-2px);
}

.convert-btn:disabled {
  background: #cccccc;
  cursor: not-allowed;
}

.cancel-btn {
  background: #f44336;
  color: white;
}

.cancel-btn:hover:not(:disabled) {
  background: #d32f2f;
}

.progress-section {
  margin-top: 20px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.progress-label {
  font-weight: 600;
  color: #333;
}

.progress-percentage {
  font-weight: 600;
  color: #2196f3;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: #ddd;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4caf50, #45a049);
  transition: width 0.3s ease;
}

.progress-details {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 12px;
  color: #666;
}

.result-section {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 30px;
}

.result-section h3 {
  margin-bottom: 15px;
  color: #333;
}

.result-content {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
}

.result-preview {
  background: #2d3748;
  border-radius: 8px;
  overflow: hidden;
}

.result-video {
  width: 100%;
  height: auto;
  display: block;
}

.result-info {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.result-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: white;
  border-radius: 6px;
}

.detail-label {
  font-weight: 600;
  color: #666;
}

.detail-value {
  font-weight: 600;
  color: #333;
}

.detail-value.high-compression {
  color: #4caf50;
}

.detail-value.medium-compression {
  color: #ff9800;
}

.detail-value.low-compression {
  color: #f44336;
}

.result-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.download-btn,
.another-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.download-btn {
  background: #4caf50;
  color: white;
}

.download-btn:hover {
  background: #45a049;
}

.another-btn {
  background: #2196f3;
  color: white;
}

.another-btn:hover {
  background: #1976d2;
}

.info-section {
  background: #e3f2fd;
  border-left: 4px solid #2196f3;
  padding: 20px;
  border-radius: 0 8px 8px 0;
}

.info-section h3 {
  color: #1565c0;
  margin-bottom: 15px;
}

.format-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.format-item {
  color: #424242;
  line-height: 1.5;
}

.tool-footer {
  text-align: center;
  padding: 20px;
  color: #757575;
  font-size: 14px;
  border-top: 1px solid #e0e0e0;
}

@media (max-width: 768px) {
  .tool-content {
    padding: 20px;
  }

  .upload-actions,
  .conversion-actions,
  .result-actions {
    flex-direction: column;
  }

  .analysis-grid,
  .options-grid {
    grid-template-columns: 1fr;
  }

  .result-content {
    grid-template-columns: 1fr;
  }

  .progress-details {
    flex-direction: column;
    gap: 5px;
  }
}
</style>